<template>
  <div>
    <a href="/audit_workorder" @click="me(i.wid)" v-for="i in messages">
      {{i.name}}
      <span v-if="i.read==true">[已读]</span>
      <span v-else>[未读]</span>
      <br>
    </a>
  </div>
</template>

<script>
export default {
  name: "message",
  data() {
    return {
      messages:[],
    }
  },
  methods: {
    me(id){
      this.$axios({
        url: 'http://127.0.0.1:8000/z/message/?id=' + id,
        method:'put',
        data:{'uid':localStorage.getItem('uid')}
      }).then(res => {
        console.log(res.data)
        this.messages = res.data.message
      })
    }
  },
  created() {
    this.$axios({
      url: 'http://127.0.0.1:8000/z/message/?uid=' + localStorage.getItem('uid')
    }).then(res => {
      console.log(res.data)
      this.messages = res.data.message
    })
  }
}
</script>

<style scoped>

</style>
